.TH std::ranges::adjacent_view::adjacent_view 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::ranges::adjacent_view::adjacent_view \- std::ranges::adjacent_view::adjacent_view

.SH Synopsis
   adjacent_view() requires std::default_initializable<V> = default; \fB(1)\fP (since C++23)
   constexpr explicit adjacent_view( V base );                       \fB(2)\fP (since C++23)

   Constructs an adjacent_view.

   1) Default constructor. Value-initializes the underlying view.
   2) Initializes the underlying view base_ with std::move(base).

.SH Parameters

   base - the underlying view

.SH Example


// Run this code

 #include <iostream>
 #include <ranges>
 #include <string>
 #include <tuple>

 template<class... Ts>
 void print(std::tuple<Ts...> const& tuple)
 {
     std::apply([&](auto&& arg, auto&&... args)
     {
         std::cout << arg;
         ((std::cout << args), ...);
     }, tuple);
     std::cout << '\\n';
 }

 int main()
 {
     const std::string v{"ABCDEF"};
     constexpr int window_size{4};

     std::cout << "v: " << v << '\\n';

     auto view = std::views::adjacent<window_size>(v); // overload (2)

     for (auto const& tuple : view)
         print(tuple);
 }

.SH Output:

 v: ABCDEF
 ABCD
 BCDE
 CDEF
